"use strict";
cc._RF.push(module, '3e566CcZnFKaLt2pM93tjms', 'ChooseEquipViewUI');
// scripts/ChooseEquipViewUI.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var a = e("NotifyEventType"),
    n = e("GlobalParams"),
    i = e("AssetsManager"),
    r = e("ModuleUI"),
    s = e("EquipInfo"),
    l = cc._decorator,
    _ = l.ccclass,
    c = l.property,
    d = function (e) {
  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    return t.time_bar = null, t.hero_view_ui = null, t.equip_view_ui = null, t.continue_btn = null, t.now_equip_id = 0, t.choose_equip_index = 0, t;
  }

  return nn(t, e), t.prototype.initView = function () {
    e.prototype.initView.call(this), this.continue_btn.active = !1, this.equip_view_ui.active = !0, this.choose_equip_index = -1, this.showHeroInfo(), this.showEquipViewInfo();
  }, t.prototype.OnClick = function (t) {
    e.prototype.OnClick.call(this, t);
    var o = t.node,
        n = o.name;

    switch (n) {
      case "continue_btn":
        this.emitEvent(a["default"].SEND_CONTINUE_D_FIGHT_GAME), this.closePopup();
        break;

      case "qeuip_0_0":
      case "qeuip_0_1":
      case "qeuip_0_2":
      case "qeuip_1_0":
      case "qeuip_1_1":
      case "qeuip_1_2":
      case "qeuip_2_0":
      case "qeuip_2_1":
      case "qeuip_2_2":
        if (this.continue_btn.active) return;
        var i = Number(n.substring(6, 7)),
            r = Number(n.substring(8, 9));
        this.getEquipInfo(i, r, o);
    }
  }, t.prototype.showHeroInfo = function () {
    for (var e = function e(_e) {
      var o = t.hero_view_ui.children[_e],
          a = n.GlobalParams.MatchGamePlayer[_e].role_id;
      t.uiManager.getRoleSkele(a, function (e) {
        o.getChildByName("role").getComponent(sp.Skeleton).skeletonData = e, o.getChildByName("role").getComponent(sp.Skeleton).setAnimation(0, "battle_idle", !0);
      });

      for (var r = o.getChildByName("equip_view"), l = 0; l < 3; l++) {
        var _ = r.children[l],
            c = n.GlobalParams.DHeroEquipInfo.hero_equip[_e];
        _.children[1].active = -1 != c[l], -1 != c[l] && (_.children[1].getComponent(cc.Sprite).spriteFrame = i["default"].getInstance().getEquipIconFrame("equip_" + c[l]), _.children[1].children[0].getComponent(cc.Label).string = s["default"].eqquip_info[c[l]].eq_name);
      }
    }, t = this, o = 0; o < 3; o++) {
      e(o);
    }
  }, t.prototype.showEquipViewInfo = function () {
    if (this.choose_equip_index++, this.choose_equip_index < n.GlobalParams.DHeroEquipInfo.get_equip.length) {
      this.now_equip_id = n.GlobalParams.DHeroEquipInfo.get_equip[this.choose_equip_index];
      var e = s["default"].eqquip_info[this.now_equip_id];
      this.equip_view_ui.children[0].getComponent(cc.Sprite).spriteFrame = i["default"].getInstance().getEquipIconFrame("equip_" + this.now_equip_id), this.equip_view_ui.children[1].getComponent(cc.Label).string = e.eq_name;

      for (var t = "", o = 0; o < e.eq_int.length; o++) {
        t += 0 != o ? "\n" : "", t += e.eq_int[o];
      }

      this.equip_view_ui.children[2].getComponent(cc.Label).string = t;
      var a = "";

      for (o = 0; o < e.eq_skill_des.length; o++) {
        a += 0 != o ? "\n" : "", a += e.eq_skill_des[o];
      }

      this.equip_view_ui.children[3].getComponent(cc.Label).string = a, this.showCountDown();
    } else this.equip_view_ui.active = !1, this.continue_btn.active = !0;
  }, t.prototype.showCountDown = function () {
    var e = this;
    this.time_bar.width = 950, cc.tween(this.time_bar).to(5, {
      width: 0
    }).call(function () {
      for (var t = 0, o = 0, a = null, i = 0; i < 3; i++) {
        var r = n.GlobalParams.DHeroEquipInfo.hero_equip[i].indexOf(-1);

        if (-1 != r) {
          t = i, o = r, a = e.hero_view_ui.children[t].getChildByName("equip_view").children[o];
          break;
        }
      }

      e.getEquipInfo(t, o, a);
    }).start();
  }, t.prototype.getEquipInfo = function (e, t, o) {
    n.GlobalParams.DHeroEquipInfo.hero_equip[e][t] = this.now_equip_id;
    var a = o.children[1];
    a.getComponent(cc.Sprite).spriteFrame = i["default"].getInstance().getEquipIconFrame("equip_" + this.now_equip_id), a.children[0].getComponent(cc.Label).string = s["default"].eqquip_info[this.now_equip_id].eq_name, a.active = !0, n.GlobalParams.MatchGamePlayer[e].equip_info[t] = this.now_equip_id, this.time_bar.stopAllActions(), this.showEquipViewInfo();
  }, oo([c(cc.Node)], t.prototype, "time_bar", void 0), oo([c(cc.Node)], t.prototype, "hero_view_ui", void 0), oo([c(cc.Node)], t.prototype, "equip_view_ui", void 0), oo([c(cc.Node)], t.prototype, "continue_btn", void 0), oo([_], t);
}(r["default"]);

o["default"] = d;

cc._RF.pop();